"use strict";
cc._RF.push(module, '2abf0A6ll1IhJlv3bhcjUJN', 'GbzDataManager');
// scripts/manager/GbzDataManager.ts

"use strict";
// Created by carolsail
Object.defineProperty(exports, "__esModule", { value: true });
var GbzEnum_1 = require("../GbzEnum");
var GbzUtils_1 = require("../GbzUtils");
var DATA_STORAGE_KEY = 'CC2_SCREWBOX';
var DATA_TIMERS = 600; //185
var GbzDataManager = /** @class */ (function () {
    function GbzDataManager() {
        this.status = GbzEnum_1.ENUM_STATUS.UNRUN;
        this.loading_rate = 0;
        this.game_music = true;
        this.game_sound = true;
        this.game_level = 1;
        this.game_level_current = 1;
        this.game_level_max = 20;
        this.data_timer = DATA_TIMERS;
        this.data_revive_time = 60;
        this.data_time_count = 0;
        this.skillIndex = 0;
        this.isSkill = false;
        this.score = 0;
        this.scoreMax = 0;
    }
    GbzDataManager.getIns = function () {
        if (this._ins === null) {
            this._ins = new GbzDataManager();
        }
        return this._ins;
    };
    Object.defineProperty(GbzDataManager, "ins", {
        get: function () {
            return this.getIns();
        },
        enumerable: false,
        configurable: true
    });
    GbzDataManager.prototype.reset = function () {
        this.status = GbzEnum_1.ENUM_STATUS.UNRUN;
        this.data_timer = DATA_TIMERS;
        this.data_time_count = 0;
        this.isSkill = false;
    };
    GbzDataManager.prototype.store = function () {
        cc.sys.localStorage.setItem(DATA_STORAGE_KEY, JSON.stringify({
            game_music: this.game_music,
            game_sound: this.game_sound,
            game_level: this.game_level,
            score: this.score,
            scoreMax: this.scoreMax
        }));
    };
    GbzDataManager.prototype.restore = function () {
        var _data = cc.sys.localStorage.getItem(DATA_STORAGE_KEY);
        try {
            var data = JSON.parse(_data);
            this.game_music = (data === null || data === void 0 ? void 0 : data.game_music) === false ? false : true;
            this.game_sound = (data === null || data === void 0 ? void 0 : data.game_sound) === false ? false : true;
            this.game_level = typeof data.game_level == 'number' ? data.game_level : 1;
            this.score = typeof data.score == 'number' ? data.score : 0;
            this.scoreMax = typeof data.scoreMax == 'number' ? data.scoreMax : 0;
        }
        catch (_a) {
            this.game_music = true;
            this.game_sound = true;
            this.game_level = 2;
            this.score = 0;
            this.scoreMax = 0;
        }
        this.game_level_current = this.game_level;
        if (this.game_level_current > this.game_level_max)
            this.game_level_current = GbzUtils_1.random(1, this.game_level_max);
    };
    GbzDataManager._ins = null;
    return GbzDataManager;
}());
exports.default = GbzDataManager;

cc._RF.pop();